package com.example.demo.actor;

import akka.actor.AbstractActor;
import com.example.demo.model.Greeting;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

/**
 * Created by Administrator on 2018/2/8.
 */
@Component
@Scope("prototype")
public class PrinterActor extends AbstractActor {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Override
    public Receive createReceive() {
        return receiveBuilder()
                .match(Greeting.class, greeting ->
                        logger.info(greeting.getWords()))
                .matchAny(o -> logger.info("received unknown message"))
                .build();
    }
}
